package com.chinacache.maint.workorder.service;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.transaction.annotation.Transactional;

import com.chinacache.maint.commons.orm.hibernate.Page;
import com.chinacache.maint.commons.orm.hibernate.SimpleHibernateDao;
import com.chinacache.maint.workorder.entity.FlowFieldClass;

@Transactional
public class FlowFieldClassManager {
	private SimpleHibernateDao<FlowFieldClass, Integer> flowFieldClassDao;

	@Required
	public void setSessionFactory(SessionFactory sessionFactory) {
		flowFieldClassDao = new SimpleHibernateDao<FlowFieldClass, Integer>(sessionFactory,
				FlowFieldClass.class);
	}

	@Transactional(readOnly = true)
	public FlowFieldClass getFlowFieldClass(Integer id) {
		return flowFieldClassDao.findById(id);
	}

	@Transactional(readOnly = true)
	public Page<FlowFieldClass> getAllFlowFieldClass(Page<FlowFieldClass> page) {
		return flowFieldClassDao.findAll(page);
	}

	public void saveFlowFieldClass(FlowFieldClass flowFieldClass) {
		flowFieldClassDao.save(flowFieldClass);
	}

	public void deleteFlowFieldClass(Integer id) {
		FlowFieldClass flowFieldClass = flowFieldClassDao.findById(id);
		flowFieldClassDao.delete(flowFieldClass);
	}

	public void updateFlowFieldClass(FlowFieldClass flowFieldClass) {
		flowFieldClassDao.update(flowFieldClass);
	}

	@Transactional(readOnly = true)
	public List<FlowFieldClass> getAllFlowFieldClass() {
		return flowFieldClassDao.findAll();
	}
}
